<!-- <!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #app {
            width: 400px;
            height: 400px;
            background: rgba(0, 0, 0, 0.3);
            margin: 100px auto 0;
        }
        #li{
            width: 300px;
            height: 150px;
            background:pink;
            margin-bottom:20px;
        }
        #yu{
            width: 300px;
            height: 150px;
            background:pink;
        }
    </style>
</head>

<body>
    <div id="app">
        <Child></Child>
        <Child2></Child2>

    </div>
    <script src="./js/vue.js"></script>
    <script>
        // 注册一下
        Vue.component('Child', {
            data() {
                return {
                    id: 100
                }
            },
            template: `
        <div id="li">
          <h3>您的请求id为：{{ id }}</h3>
          <hr/>
          <button @click="aa">自增</button>
          <button @click="bb">自减</button>
        </div>
      `,
            methods: {
                aa() {
                    this.id++
                },
                bb() {
                    this.id--
                }
            }

        }),
            Vue.component('Child2', {
                data() {
                    return {
                        id: 100
                    }
                },
                template: `
        <div id="yu">
          <h3>您的请求id为：{{ id }}</h3>
          <hr/>
          <button @click="aa">自增</button>
          <button @click="bb">自减</button>
        </div>
      `,
            })

        // Vue实例 根组件
        const app = new Vue({
            el: '#app',
            data: {

            }
        })
    </script>
</body>

</html> -->





<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #app {
            width: 400px;
            height: 400px;
            background: rgba(0, 0, 0, 0.3);
            margin: 100px auto 0;
        }

        #li {
            width: 300px;
            height: 150px;
            background: pink;
            margin-bottom: 20px;
        }

    </style>
</head>

<body>
    <div id="app">
        <Child></Child>
        <Child2></Child2>

    </div>
    <script src="./js/vue.js"></script>
    <script  type="text/x-template" id="child" >
        <div id="li">
          <h3>您的请求id为：{{ id }}</h3>
          <hr/>
          <button @click="aa">自增</button>
          <button @click="bb" > 自减</button >
        </div >
    </script>
    <script>
            // 注册一下
            Vue.component('Child', {
                data() {
                    return {
                        id: 100
                    }
                },
                template:'#child',
                methods: {
                    aa() {
                        this.id++
                    },
                    bb() {
                        this.id--
                    }
                }

            })


        // Vue实例 根组件
        const app = new Vue({
            el: '#app',
            data: {

            }
        })
    </script>
</body>

</html>